package com.douqu.game.core.entity.activity;

import com.bean.core.buffer.ByteBuffer;
import com.douqu.game.core.entity.EntityObject;
import com.douqu.game.core.protobuf.SGCommonProto;

/**
 * 阵营排行对象
 * @Author: Bean
 * @Description:
 * @Date: 2018-03-16 14:14
 */
public class RankCamp extends EntityObject {

    private int camp;

    private int value;

    public RankCamp()
    {

    }

    public RankCamp(int camp, int value)
    {
        this.camp = camp;
        this.value = value;
    }

    public void loadFrom(ByteBuffer buffer)
    {
        this.camp = buffer.readByte();
        this.value = buffer.readInt();
    }

    public void writeTo(ByteBuffer buffer)
    {
        buffer.writeByte(camp);
        buffer.writeInt(value);
    }



    public void addValue(int value)
    {
        if(value <= 0)
            return;

        this.value += value;
    }

    public SGCommonProto.CommonObject.Builder parse()
    {
        SGCommonProto.CommonObject.Builder builder = SGCommonProto.CommonObject.newBuilder();
        builder.setId(camp);
        builder.setValue(value);
        return builder;
    }

    public int getCamp() {
        return camp;
    }

    public void setCamp(int camp) {
        this.camp = camp;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

}